//
// Copyright (c) 1997 Molecular Structure Corporation
//
// RESTRICTED RIGHTS NOTICE SHORT FORM (JUNE 1987)
//
// Use, reproduction, or disclosure is subject to restrictions set
// forth in Contract No. W-31-109-ENG-38 and Contract No. 
// 943072401 with the University of Chicago, Operator of
// Argonne National Laboratory.
//
// CUIreflnviewprops.cc    Initial author: YY Xiao           ?-May-1997
//    This file contains the methods to implement the user interface class
//    CUIreflnviewprops which implements a dialog that allows the user to
//    choose color, symbol and size of the reflnlist plotting.
/*
 *
 * Copyright (C) 2014 Rigaku Americas Corporation
 *                    9009 New Trails Drive
 *                    The Woodlands, TX, USA  77381
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *    * Redistributions of source code must retain the above copyright
 *      notice(s), this list of conditions and the following disclaimer.
 *    * Redistributions in binary form must reproduce the above copyright
 *      notice(s), this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *    * Neither the name of the Rigaku Americas Corporation nor the 
 *      names of its contributors may be used to endorse or promote products
 *      derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL RIGAKU AMERICAS CORPORATION BE LIABLE 
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA OR PROFITS; OR BUSINESS INTERUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 *
*/ 

//
// README: Portions of this file are merged at file generation
// time. Edits can be made *only* in between specified code blocks, look
// for keywords <Begin user code> and <End user code>.
//
/////////////////////////////////////////////////////////////
//
// Source file for CUIreflnviewprops
//
//    Created by Builder Xcessory Version 5.0.
//    Generated by Code Generator Xcessory 5.0 (05/22/98) .
//
//    This class is a user interface "component", as described
//    in "Object-Oriented Programming with C++ and OSF/Motif",
//    by Douglas Young, Prentice Hall, 1992. ISBN 0-13-630252-1
//
/////////////////////////////////////////////////////////////


// Begin user code block <file_comments>
// End user code block <file_comments>

#include <X11/StringDefs.h>
#include <Xm/SelectioB.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
#include <Xm/TextF.h>
#include "CUIreflnviewprops.h"
#include "CUIom9.h"
#include "Cstring.h"

//
// Convenience functions from utilities file.
//
extern void RegisterBxConverters(XtAppContext);
extern XtPointer BX_CONVERT(Widget, char *, char *, int, Boolean *);
extern XtPointer BX_DOUBLE(double);
extern XtPointer BX_SINGLE(float);
extern void BX_MENU_POST(Widget, XtPointer, XEvent *, Boolean *);
extern Pixmap XPM_PIXMAP(Widget, char **);
extern void BX_SET_BACKGROUND_COLOR(Widget, ArgList, Cardinal *, Pixel);


// Begin user code block <head>
// End user code block <head>

//
// This table is used to define class resources that are placed
// in app-defaults. This table is necessary so each instance
// of this class has the proper default resource values set.
// This eliminates the need for each instance to have
// its own app-defaults values. This table must be NULL terminated.
//
#if defined(cxx_bx_compat)

Boolean CUIreflnviewprops::_initAppDefaults = True;
UIAppDefault  CUIreflnviewprops::_appDefaults[] = {
    {"", NULL, "dialogTitle", NULL},
    {"", NULL, "selectionLabelString", NULL},
    {"", NULL, "okLabelString", NULL},
    {"", NULL, "helpLabelString", NULL},
    {"", NULL, "cancelLabelString", NULL},
    {"", NULL, "applyLabelString", NULL},
    {"cUIom9RestrictRange", "om9", "labelString", NULL},
    {"cUIom9RestrictRange", "pb8", "background", NULL},
    {"cUIom9RestrictRange", "pb8", "labelString", NULL},
    {"cUIom9RestrictRange", "pb7", "background", NULL},
    {"cUIom9RestrictRange", "pb7", "labelString", NULL},
    {"cUIom9RestrictRange", "pb6", "background", NULL},
    {"cUIom9RestrictRange", "pb6", "labelString", NULL},
    {"cUIom9RestrictRange", "pb5", "background", NULL},
    {"cUIom9RestrictRange", "pb5", "labelString", NULL},
    {"cUIom9RestrictRange", "pb4", "background", NULL},
    {"cUIom9RestrictRange", "pb4", "labelString", NULL},
    {"cUIom9RestrictRange", "pb3", "background", NULL},
    {"cUIom9RestrictRange", "pb3", "labelString", NULL},
    {"cUIom9RestrictRange", "pb2", "background", NULL},
    {"cUIom9RestrictRange", "pb2", "labelString", NULL},
    {"cUIom9RestrictRange", "pb1", "background", NULL},
    {"cUIom9RestrictRange", "pb1", "labelString", NULL},
    {"cUIom9RestrictRange", "pb0", "background", NULL},
    {"cUIom9RestrictRange", "pb0", "labelString", NULL},
    {"cUIom9PredObs", "om9", "labelString", NULL},
    {"cUIom9PredObs", "pb8", "background", NULL},
    {"cUIom9PredObs", "pb8", "labelString", NULL},
    {"cUIom9PredObs", "pb7", "background", NULL},
    {"cUIom9PredObs", "pb7", "labelString", NULL},
    {"cUIom9PredObs", "pb6", "background", NULL},
    {"cUIom9PredObs", "pb6", "labelString", NULL},
    {"cUIom9PredObs", "pb5", "background", NULL},
    {"cUIom9PredObs", "pb5", "labelString", NULL},
    {"cUIom9PredObs", "pb4", "background", NULL},
    {"cUIom9PredObs", "pb4", "labelString", NULL},
    {"cUIom9PredObs", "pb3", "background", NULL},
    {"cUIom9PredObs", "pb3", "labelString", NULL},
    {"cUIom9PredObs", "pb2", "background", NULL},
    {"cUIom9PredObs", "pb2", "labelString", NULL},
    {"cUIom9PredObs", "pb1", "background", NULL},
    {"cUIom9PredObs", "pb1", "labelString", NULL},
    {"cUIom9PredObs", "pb0", "background", NULL},
    {"cUIom9PredObs", "pb0", "labelString", NULL},
    {"cUIom9Symbol", "om9", "labelString", NULL},
    {"cUIom9Symbol", "pb8", "background", NULL},
    {"cUIom9Symbol", "pb8", "labelString", NULL},
    {"cUIom9Symbol", "pb7", "background", NULL},
    {"cUIom9Symbol", "pb7", "labelString", NULL},
    {"cUIom9Symbol", "pb6", "background", NULL},
    {"cUIom9Symbol", "pb6", "labelString", NULL},
    {"cUIom9Symbol", "pb5", "background", NULL},
    {"cUIom9Symbol", "pb5", "labelString", NULL},
    {"cUIom9Symbol", "pb4", "background", NULL},
    {"cUIom9Symbol", "pb4", "labelString", NULL},
    {"cUIom9Symbol", "pb3", "background", NULL},
    {"cUIom9Symbol", "pb3", "labelString", NULL},
    {"cUIom9Symbol", "pb2", "background", NULL},
    {"cUIom9Symbol", "pb2", "labelString", NULL},
    {"cUIom9Symbol", "pb1", "background", NULL},
    {"cUIom9Symbol", "pb1", "labelString", NULL},
    {"cUIom9Symbol", "pb0", "background", NULL},
    {"cUIom9Symbol", "pb0", "labelString", NULL},
    {"cUIom9Color", "om9", "labelString", NULL},
    {"cUIom9Filename", "pb8", "background", NULL},
    {"cUIom9Filename", "pb8", "labelString", NULL},
    {"cUIom9Filename", "pb7", "background", NULL},
    {"cUIom9Filename", "pb7", "labelString", NULL},
    {"cUIom9Filename", "pb6", "background", NULL},
    {"cUIom9Filename", "pb6", "labelString", NULL},
    {"cUIom9Filename", "pb5", "background", NULL},
    {"cUIom9Filename", "pb5", "labelString", NULL},
    {"cUIom9Filename", "pb4", "background", NULL},
    {"cUIom9Filename", "pb4", "labelString", NULL},
    {"cUIom9Filename", "pb3", "background", NULL},
    {"cUIom9Filename", "pb3", "labelString", NULL},
    {"cUIom9Filename", "pb2", "background", NULL},
    {"cUIom9Filename", "pb2", "labelString", NULL},
    {"cUIom9Filename", "pb1", "background", NULL},
    {"cUIom9Filename", "pb1", "labelString", NULL},
    {"cUIom9Filename", "pb0", "background", NULL},
    {"cUIom9Filename", "pb0", "labelString", NULL},
    {"lbRotRange", NULL, "labelString", NULL},
    {"lbRestrictRange", NULL, "labelString", NULL},
    {"lbPredObs", NULL, "labelString", NULL},
    {"lbColor", NULL, "labelString", NULL},
    {"lbSymbol", NULL, "labelString", NULL},
    {"tfSize", NULL, "value", NULL},
    {"lbSize", NULL, "labelString", NULL},
    {"lbReflnName", NULL, "labelString", NULL},
    {NULL, NULL, NULL, NULL}
};
#endif

// These are default resources for widgets in objects of this class
// All resources will be prepended by *<name> at instantiation,
// where <name> is the name of the specific instance, as well as the
// name of the baseWidget. These are only defaults, and may be overriden
// in a resource file by providing a more specific resource name

String  CUIreflnviewprops::_defaultCUIreflnviewpropsResources[] = {
        NULL
};

//
// Old style constructor, for compatibility only.
//
CUIreflnviewprops::CUIreflnviewprops(const char *name, Widget parent) : 
    UIComponent(name)

// Begin user code block <alt_superclass>
// End user code block <alt_superclass>
{
    
    // Begin user code block <alt_constructor>
    // End user code block <alt_constructor>
    create(parent);
}

//
// Class Constructor.
//
CUIreflnviewprops::CUIreflnviewprops(const char *name) : UIComponent(name)

// Begin user code block <superclass>
// End user code block <superclass>
{
    
    // Begin user code block <constructor>

  m_prvOKCallback = NULL;
  m_pObj          = NULL;
 
  m_tReflnProps.nReflnSymbol    = 0;
  m_tReflnProps.a6fReflnSize[0] = 25.0;
  m_tReflnProps.a6fReflnSize[1] = 25.0;
  m_tReflnProps.a6fReflnSize[2] = 0.0;
  m_tReflnProps.a6fReflnSize[3] = 0.0;
  m_tReflnProps.a6fReflnSize[4] = 0.0;
  m_tReflnProps.a6fReflnSize[5] = 0.0;
  m_tReflnProps.sReflnColor     = "red";
  m_tReflnProps.nReflnPredObs   = 0;
    // End user code block <constructor>
}


//
// Minimal Destructor. Base class destroys widgets.
//
CUIreflnviewprops::~CUIreflnviewprops() 
{
    
    // Begin user code block <destructor>
    // End user code block <destructor>
    delete []  _clientDataStructs;
}

//
// Handle creation of all widgets in the class.
//
void CUIreflnviewprops::create(Widget parent) 
{
    Cardinal ac = 0;
    Arg      args[256];
    Cardinal cdc = 0;
    Boolean  argok = False;
    
    _clientDataStructs = new UICallbackStruct[4];
    
    //
    // Load any class-defaulted resources for this object.
    //
    setDefaultResources(parent, _defaultCUIreflnviewpropsResources);
    
#if defined(cxx_bx_compat)
    //
    // Setup app-defaults fallback table if not already done.
    //
    if (_initAppDefaults)
    {
        initAppDefaults(parent, "CUIreflnviewprops", _appDefaults);
        _initAppDefaults = False;
    }
    //
    // Now set the app-defaults for this instance.
    //
    setAppDefaults(parent, _appDefaults, _name, False);
#endif
    
    //
    // Register the converters for the widgets.
    //
    RegisterBxConverters(XtWidgetToApplicationContext(parent));
    XtInitializeWidgetClass((WidgetClass)xmSelectionBoxWidgetClass);
    XtInitializeWidgetClass((WidgetClass)xmFormWidgetClass);
    XtInitializeWidgetClass((WidgetClass)xmLabelWidgetClass);
    XtInitializeWidgetClass((WidgetClass)xmTextFieldWidgetClass);
    
    //
    // Create an unmanaged widget as the top of the hierarchy.
    //
    
    ac = 0;
    XtSetArg(args[ac], XmNsensitive, True); ac++;
    XtSetArg(args[ac], XmNdialogType, XmDIALOG_PROMPT); ac++;
    XtSetArg(args[ac], XmNx, 688); ac++;
    XtSetArg(args[ac], XmNy, 483); ac++;
    XtSetArg(args[ac], XmNwidth, 422); ac++;
    XtSetArg(args[ac], XmNheight, 425); ac++;
    _CUIreflnviewprops = XmCreateSelectionBox(parent,
        _name,
        args, 
        ac);
    _clientDataStructs[cdc].object = this;
    _clientDataStructs[cdc].client_data = (XtPointer)"EditReflnView$$";
    XtAddCallback(_CUIreflnviewprops,
        XmNhelpCallback,
        CUIreflnviewprops::vHTMLHelpCallback,
        (XtPointer)&_clientDataStructs[cdc]);
    cdc++;
    _clientDataStructs[cdc].object = this;
    _clientDataStructs[cdc].client_data = (XtPointer)0;
    XtAddCallback(_CUIreflnviewprops,
        XmNokCallback,
        CUIreflnviewprops::vReflnViewPropSelectCBCallback,
        (XtPointer)&_clientDataStructs[cdc]);
    cdc++;
    _clientDataStructs[cdc].object = this;
    _clientDataStructs[cdc].client_data = (XtPointer)0;
    XtAddCallback(_CUIreflnviewprops,
        XmNcancelCallback,
        CUIreflnviewprops::vReflnViewPropSelectCBCallback,
        (XtPointer)&_clientDataStructs[cdc]);
    cdc++;
    _clientDataStructs[cdc].object = this;
    _clientDataStructs[cdc].client_data = (XtPointer)0;
    XtAddCallback(_CUIreflnviewprops,
        XmNapplyCallback,
        CUIreflnviewprops::vReflnViewPropSelectCBCallback,
        (XtPointer)&_clientDataStructs[cdc]);
    cdc++;
    
    _w = _CUIreflnviewprops;
    //
    // Add a callback to guard against widget destruction..
    //
    installDestroyHandler();
    
    ac = 0;
    XtSetArg(args[ac], XmNsensitive, True); ac++;
    XtSetArg(args[ac], XmNresizePolicy, XmRESIZE_GROW); ac++;
    XtSetArg(args[ac], XmNx, 11); ac++;
    XtSetArg(args[ac], XmNy, 11); ac++;
    XtSetArg(args[ac], XmNwidth, 400); ac++;
    XtSetArg(args[ac], XmNheight, 280); ac++;
    _fmRefln = XmCreateForm(_CUIreflnviewprops,
        "fmRefln",
        args, 
        ac);
    XtManageChild(_fmRefln);
    
#if defined(cxx_bx_compat)
    setAppDefaults(_fmRefln, _appDefaults, "cUIom9RestrictRange", True);
#endif
    _cUIom9RestrictRange = new CUIom9("cUIom9RestrictRange");
    
    // Begin user code block <new_cUIom9RestrictRange>
    // End user code block <new_cUIom9RestrictRange>
    
    _cUIom9RestrictRange->create(_fmRefln);
    _cUIom9RestrictRange->manage();
    
    //
    // Set exposed resources.
    //
    ac = 0;
    XtSetArg(args[ac], XmNx, 170); ac++;
    XtSetArg(args[ac], XmNy, 200); ac++;
    XtSetArg(args[ac], XmNwidth, 153); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    XtSetValues(_cUIom9RestrictRange->baseWidget(), args, ac);
    
#if defined(cxx_bx_compat)
    setAppDefaults(_fmRefln, _appDefaults, "cUIom9PredObs", True);
#endif
    _cUIom9PredObs = new CUIom9("cUIom9PredObs");
    
    // Begin user code block <new_cUIom9PredObs>
    // End user code block <new_cUIom9PredObs>
    
    _cUIom9PredObs->create(_fmRefln);
    _cUIom9PredObs->manage();
    
    //
    // Set exposed resources.
    //
    ac = 0;
    XtSetArg(args[ac], XmNx, 170); ac++;
    XtSetArg(args[ac], XmNy, 160); ac++;
    XtSetArg(args[ac], XmNwidth, 170); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    XtSetValues(_cUIom9PredObs->baseWidget(), args, ac);
    
#if defined(cxx_bx_compat)
    setAppDefaults(_fmRefln, _appDefaults, "cUIom9Symbol", True);
#endif
    _cUIom9Symbol = new CUIom9("cUIom9Symbol");
    
    // Begin user code block <new_cUIom9Symbol>
    // End user code block <new_cUIom9Symbol>
    
    _cUIom9Symbol->create(_fmRefln);
    _cUIom9Symbol->manage();
    
    //
    // Set exposed resources.
    //
    ac = 0;
    XtSetArg(args[ac], XmNx, 170); ac++;
    XtSetArg(args[ac], XmNy, 40); ac++;
    XtSetArg(args[ac], XmNwidth, 146); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    XtSetValues(_cUIom9Symbol->baseWidget(), args, ac);
    
#if defined(cxx_bx_compat)
    setAppDefaults(_fmRefln, _appDefaults, "cUIom9Color", True);
#endif
    _cUIom9Color = new CUIom9("cUIom9Color");
    
    // Begin user code block <new_cUIom9Color>
    // End user code block <new_cUIom9Color>
    
    _cUIom9Color->create(_fmRefln);
    _cUIom9Color->manage();
    
    //
    // Set exposed resources.
    //
    ac = 0;
    XtSetArg(args[ac], XmNx, 170); ac++;
    XtSetArg(args[ac], XmNy, 120); ac++;
    XtSetArg(args[ac], XmNwidth, 146); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    XtSetValues(_cUIom9Color->baseWidget(), args, ac);
    
#if defined(cxx_bx_compat)
    setAppDefaults(_fmRefln, _appDefaults, "cUIom9Filename", True);
#endif
    _cUIom9Filename = new CUIom9("cUIom9Filename");
    
    // Begin user code block <new_cUIom9Filename>
    // End user code block <new_cUIom9Filename>
    
    _cUIom9Filename->create(_fmRefln);
    _cUIom9Filename->manage();
    
    //
    // Set exposed resources.
    //
    ac = 0;
    XtSetArg(args[ac], XmNx, 170); ac++;
    XtSetArg(args[ac], XmNy, 0); ac++;
    XtSetArg(args[ac], XmNwidth, 120); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    XtSetValues(_cUIom9Filename->baseWidget(), args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNalignment, XmALIGNMENT_END); ac++;
    XtSetArg(args[ac], XmNtraversalOn, False); ac++;
    XtSetArg(args[ac], XmNmarginHeight, 2); ac++;
    XtSetArg(args[ac], XmNx, 0); ac++;
    XtSetArg(args[ac], XmNy, 240); ac++;
    XtSetArg(args[ac], XmNwidth, 170); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    _lbRotRange = XmCreateLabel(_fmRefln,
        "lbRotRange",
        args, 
        ac);
    XtManageChild(_lbRotRange);
    
    ac = 0;
    XtSetArg(args[ac], XmNalignment, XmALIGNMENT_END); ac++;
    XtSetArg(args[ac], XmNtraversalOn, False); ac++;
    XtSetArg(args[ac], XmNmarginHeight, 2); ac++;
    XtSetArg(args[ac], XmNx, 0); ac++;
    XtSetArg(args[ac], XmNy, 200); ac++;
    XtSetArg(args[ac], XmNwidth, 170); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    _lbRestrictRange = XmCreateLabel(_fmRefln,
        "lbRestrictRange",
        args, 
        ac);
    XtManageChild(_lbRestrictRange);
    
    ac = 0;
    XtSetArg(args[ac], XmNalignment, XmALIGNMENT_END); ac++;
    XtSetArg(args[ac], XmNtraversalOn, False); ac++;
    XtSetArg(args[ac], XmNmarginHeight, 2); ac++;
    XtSetArg(args[ac], XmNx, 0); ac++;
    XtSetArg(args[ac], XmNy, 160); ac++;
    XtSetArg(args[ac], XmNwidth, 170); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    _lbPredObs = XmCreateLabel(_fmRefln,
        "lbPredObs",
        args, 
        ac);
    XtManageChild(_lbPredObs);
    
    ac = 0;
    XtSetArg(args[ac], XmNalignment, XmALIGNMENT_END); ac++;
    XtSetArg(args[ac], XmNtraversalOn, False); ac++;
    XtSetArg(args[ac], XmNmarginHeight, 2); ac++;
    XtSetArg(args[ac], XmNx, 0); ac++;
    XtSetArg(args[ac], XmNy, 120); ac++;
    XtSetArg(args[ac], XmNwidth, 170); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    _lbColor = XmCreateLabel(_fmRefln,
        "lbColor",
        args, 
        ac);
    XtManageChild(_lbColor);
    
    ac = 0;
    XtSetArg(args[ac], XmNx, 180); ac++;
    XtSetArg(args[ac], XmNy, 240); ac++;
    XtSetArg(args[ac], XmNwidth, 220); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    _tfRotRange = XmCreateTextField(_fmRefln,
        "tfRotRange",
        args, 
        ac);
    XtManageChild(_tfRotRange);
    
    ac = 0;
    XtSetArg(args[ac], XmNalignment, XmALIGNMENT_END); ac++;
    XtSetArg(args[ac], XmNtraversalOn, False); ac++;
    XtSetArg(args[ac], XmNmarginHeight, 2); ac++;
    XtSetArg(args[ac], XmNx, 0); ac++;
    XtSetArg(args[ac], XmNy, 40); ac++;
    XtSetArg(args[ac], XmNwidth, 170); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    _lbSymbol = XmCreateLabel(_fmRefln,
        "lbSymbol",
        args, 
        ac);
    XtManageChild(_lbSymbol);
    
    ac = 0;
    XtSetArg(args[ac], XmNx, 180); ac++;
    XtSetArg(args[ac], XmNy, 80); ac++;
    XtSetArg(args[ac], XmNwidth, 220); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    _tfSize = XmCreateTextField(_fmRefln,
        "tfSize",
        args, 
        ac);
    XtManageChild(_tfSize);
    
    ac = 0;
    XtSetArg(args[ac], XmNalignment, XmALIGNMENT_END); ac++;
    XtSetArg(args[ac], XmNtraversalOn, False); ac++;
    XtSetArg(args[ac], XmNmarginHeight, 2); ac++;
    XtSetArg(args[ac], XmNx, 0); ac++;
    XtSetArg(args[ac], XmNy, 80); ac++;
    XtSetArg(args[ac], XmNwidth, 170); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    _lbSize = XmCreateLabel(_fmRefln,
        "lbSize",
        args, 
        ac);
    XtManageChild(_lbSize);
    
    ac = 0;
    XtSetArg(args[ac], XmNalignment, XmALIGNMENT_END); ac++;
    XtSetArg(args[ac], XmNtraversalOn, False); ac++;
    XtSetArg(args[ac], XmNmarginHeight, 2); ac++;
    XtSetArg(args[ac], XmNx, 0); ac++;
    XtSetArg(args[ac], XmNy, 0); ac++;
    XtSetArg(args[ac], XmNwidth, 170); ac++;
    XtSetArg(args[ac], XmNheight, 40); ac++;
    _lbReflnName = XmCreateLabel(_fmRefln,
        "lbReflnName",
        args, 
        ac);
    XtManageChild(_lbReflnName);
    ac = 0;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 170); ac++;
    XtSetArg(args[ac], XmNtopOffset, 200); ac++;
    XtSetValues(_cUIom9RestrictRange->baseWidget(), args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 170); ac++;
    XtSetArg(args[ac], XmNtopOffset, 160); ac++;
    XtSetValues(_cUIom9PredObs->baseWidget(), args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 170); ac++;
    XtSetArg(args[ac], XmNtopOffset, 40); ac++;
    XtSetValues(_cUIom9Symbol->baseWidget(), args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 170); ac++;
    XtSetArg(args[ac], XmNtopOffset, 120); ac++;
    XtSetValues(_cUIom9Color->baseWidget(), args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftOffset, 0); ac++;
    XtSetArg(args[ac], XmNrightOffset, 0); ac++;
    XtSetArg(args[ac], XmNtopOffset, 0); ac++;
    XtSetArg(args[ac], XmNleftWidget, _lbReflnName); ac++;
    XtSetValues(_cUIom9Filename->baseWidget(), args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 0); ac++;
    XtSetArg(args[ac], XmNtopOffset, 240); ac++;
    XtSetValues(_lbRotRange, args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 0); ac++;
    XtSetArg(args[ac], XmNtopOffset, 200); ac++;
    XtSetValues(_lbRestrictRange, args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 0); ac++;
    XtSetArg(args[ac], XmNtopOffset, 160); ac++;
    XtSetValues(_lbPredObs, args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 0); ac++;
    XtSetArg(args[ac], XmNtopOffset, 120); ac++;
    XtSetValues(_lbColor, args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 180); ac++;
    XtSetArg(args[ac], XmNrightOffset, 0); ac++;
    XtSetArg(args[ac], XmNtopOffset, 240); ac++;
    XtSetValues(_tfRotRange, args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 0); ac++;
    XtSetArg(args[ac], XmNtopOffset, 40); ac++;
    XtSetValues(_lbSymbol, args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 180); ac++;
    XtSetArg(args[ac], XmNrightOffset, 0); ac++;
    XtSetArg(args[ac], XmNtopOffset, 80); ac++;
    XtSetValues(_tfSize, args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
    XtSetArg(args[ac], XmNleftOffset, 0); ac++;
    XtSetArg(args[ac], XmNtopOffset, 80); ac++;
    XtSetValues(_lbSize, args, ac);
    
    ac = 0;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
    XtSetArg(args[ac], XmNleftOffset, 0); ac++;
    XtSetArg(args[ac], XmNtopOffset, 0); ac++;
    XtSetValues(_lbReflnName, args, ac);
    
    
    // Begin user code block <endcreate>
    m_poXhelp     = new CXhelp (_w);

    _clientDataStructs = new UICallbackStruct;
    _clientDataStructs->object = (UIComponent *)m_poXhelp;
    _clientDataStructs->client_data = (XtPointer)"EditReflnView$$";
    XtAddCallback(_CUIreflnviewprops,
        XmNhelpCallback,
        CXhelp::vHTMLHelpCallback,
        (XtPointer)_clientDataStructs);

    _clientDataStructs = new UICallbackStruct;
    _clientDataStructs->object = (UIComponent *)m_poXhelp;
    _clientDataStructs->client_data = (XtPointer)0;
    XtAddCallback(_tfSize,
		  XmNfocusCallback,
		  CXhelp::vPostOneLineCBCallback,
		  (XtPointer)_clientDataStructs);
    XtAddCallback(_tfSize,
		  XmNlosingFocusCallback,
		  CXhelp::vUnpostOneLineCBCallback,
		  (XtPointer)_clientDataStructs);

    _clientDataStructs = new UICallbackStruct;
    _clientDataStructs->object = (UIComponent *)m_poXhelp;
    _clientDataStructs->client_data = (XtPointer)0;
    XtAddCallback(_tfRotRange,
		  XmNfocusCallback,
		  CXhelp::vPostOneLineCBCallback,
		  (XtPointer)_clientDataStructs);
    XtAddCallback(_tfRotRange,
		  XmNlosingFocusCallback,
		  CXhelp::vUnpostOneLineCBCallback,
		  (XtPointer)_clientDataStructs);


    XtVaSetValues(_CUIreflnviewprops, XmNdefaultButton,
		  XmSelectionBoxGetChild(_CUIreflnviewprops,
					 XmDIALOG_APPLY_BUTTON),
		  NULL);

    _cUIom9Filename->m_pObj = this;
    _cUIom9Filename->m_prvCUIom9Callback = CUIreflnviewprops::vCUIom9CBCallback;
    _cUIom9Color->m_pObj = this;
    _cUIom9Color->m_prvCUIom9Callback = CUIreflnviewprops::vCUIom9CBCallback;
    _cUIom9Symbol->m_pObj = this;
    _cUIom9Symbol->m_prvCUIom9Callback = CUIreflnviewprops::vCUIom9CBCallback;
    _cUIom9PredObs->m_pObj = this;
    _cUIom9PredObs->m_prvCUIom9Callback = CUIreflnviewprops::vCUIom9CBCallback;
    _cUIom9RestrictRange->m_pObj = this;
    _cUIom9RestrictRange->m_prvCUIom9Callback = CUIreflnviewprops::vCUIom9CBCallback;

    XtManageChild(XmSelectionBoxGetChild(_CUIreflnviewprops,
					 XmDIALOG_APPLY_BUTTON));
    vReadWidgets(); // Get what is there to start with 

    _cUIom9RestrictRange->vScanUnmanage();
    _cUIom9PredObs->vScanUnmanage();
    _cUIom9Symbol->vScanUnmanage();

    m_sReflnFilename = "";

    // Unmanage some widgets that are not really used yet

    XtUnmanageChild(XmSelectionBoxGetChild(_CUIreflnviewprops,
					   XmDIALOG_SELECTION_LABEL));
    XtUnmanageChild(XmSelectionBoxGetChild(_CUIreflnviewprops,
					   XmDIALOG_TEXT));
    _cUIom9PredObs->unmanage();
    _cUIom9RestrictRange->unmanage();
    _cUIom9Filename->unmanage();
    XtUnmanageChild(_lbRotRange);
    XtUnmanageChild(_lbRestrictRange);
    XtUnmanageChild(_tfRotRange);
    XtUnmanageChild(_lbPredObs);
    XtUnmanageChild(_lbReflnName);

    // End user code block <endcreate>
}

//
// Classname access.
//
const char *const CUIreflnviewprops::className()
{
    return ("CUIreflnviewprops");
}

void CUIreflnviewprops::vHTMLHelpCallback(Widget w, 
    XtPointer clientData, XtPointer callData)
{
    UICallbackStruct *data = (UICallbackStruct *) clientData;
    CUIreflnviewprops *obj = (CUIreflnviewprops *)data->object;
    obj->vHTMLHelp(w, (XtPointer) data->client_data, callData);
}

void CUIreflnviewprops::vHTMLHelp(Widget w, XtPointer clientData, XtPointer callData)
{
    
    // Begin user code block <vHTMLHelp>
    // End user code block <vHTMLHelp>
}

void CUIreflnviewprops::vReflnViewPropSelectCBCallback(Widget w, 
    XtPointer clientData, XtPointer callData)
{
    UICallbackStruct *data = (UICallbackStruct *) clientData;
    CUIreflnviewprops *obj = (CUIreflnviewprops *)data->object;
    obj->vReflnViewPropSelectCB(w, (XtPointer) data->client_data, callData);
}

void CUIreflnviewprops::vReflnViewPropSelectCB(Widget w, XtPointer clientData, XtPointer callData)
{
    
    // Begin user code block <vReflnViewPropSelectCB>
  XmSelectionBoxCallbackStruct *ptCBS = 
    (XmSelectionBoxCallbackStruct *)callData;

  if (XmIsTextField(w))
    {
      if (XmCR_ACTIVATE == ptCBS->reason)
	XmProcessTraversal(w, XmTRAVERSE_NEXT);
    }
  else if (XmIsSelectionBox(w))
    {
      if ( (XmCR_OK == ptCBS->reason) || (XmCR_APPLY == ptCBS->reason) )
	{
	  vReadWidgets();
	  if (NULL != m_prvOKCallback)
	    {
	      m_prvOKCallback(m_pObj, &m_tReflnProps);
	    }
	  if (XmCR_OK == ptCBS->reason)
	    {
	      XtUnmanageChild(w);
	    }
	}
      if (XmCR_CANCEL == ptCBS->reason)
	{
	  XtUnmanageChild(w);
	}
      if (XmCR_HELP == ptCBS->reason)
	{
	  if (NULL != m_prvOKCallback)
	    {
	      m_prvOKCallback(m_pObj, NULL);
	    }
	}
    }
    // End user code block <vReflnViewPropSelectCB>
}

// Begin user code block <tail>

void
CUIreflnviewprops::vReadWidgets(void)
{
  // Read the widget values into m_tImageProps
  // Read only the textfield, option menu and slider widgets.
  // Do not read the labels.

  char *pcTemp;
  int   nStat;
  int   nTemp, nTemp2;
  double a6dTemp[6];
  Cstring sTemp;

  m_nReflnNum = _cUIom9Filename->nGetValue();
  
  pcTemp = XmTextFieldGetString(_tfSize);
  sTemp = Cstring(pcTemp);
  if (sTemp.contains(','))
    nStat = sscanf(pcTemp, "%lf,%lf,%lf,%lf,%lf,%lf", &a6dTemp[0],
		   &a6dTemp[1], &a6dTemp[2], &a6dTemp[3],
		   &a6dTemp[4],&a6dTemp[5]);
  else
    nStat = sscanf(pcTemp, "%lf %lf %lf %lf %lf %lf", &a6dTemp[0],
		   &a6dTemp[1], &a6dTemp[2], &a6dTemp[3],
		   &a6dTemp[4],&a6dTemp[5]);
  if (1 == nStat)
    {
      m_tReflnProps.a6fReflnSize[0] = a6dTemp[0];
      m_tReflnProps.a6fReflnSize[1] = a6dTemp[0];
      m_tReflnProps.a6fReflnSize[2] = 0.0;
      m_tReflnProps.a6fReflnSize[3] = 0.0;
      m_tReflnProps.a6fReflnSize[4] = 0.0;
      m_tReflnProps.a6fReflnSize[5] = 0.0;
    }
  if (2 <= nStat)
    {
      m_tReflnProps.a6fReflnSize[0] = a6dTemp[0];
      m_tReflnProps.a6fReflnSize[1] = a6dTemp[1];
      m_tReflnProps.a6fReflnSize[2] = 0.0;
      m_tReflnProps.a6fReflnSize[3] = 0.0;
      m_tReflnProps.a6fReflnSize[4] = 0.0;
      m_tReflnProps.a6fReflnSize[5] = 0.0;
    }
  if (3 == nStat)
    {
      m_tReflnProps.a6fReflnSize[2] = a6dTemp[2];
      m_tReflnProps.a6fReflnSize[3] = a6dTemp[2];
      m_tReflnProps.a6fReflnSize[4] = 0.0;
      m_tReflnProps.a6fReflnSize[5] = 0.0;
    }
  if (4 <= nStat)
    {
      m_tReflnProps.a6fReflnSize[2] = a6dTemp[2];
      m_tReflnProps.a6fReflnSize[3] = a6dTemp[3];
      m_tReflnProps.a6fReflnSize[4] = 0.0;
      m_tReflnProps.a6fReflnSize[5] = 0.0;
    }
  if (5 == nStat)
    {
      m_tReflnProps.a6fReflnSize[4] = a6dTemp[4];
      m_tReflnProps.a6fReflnSize[5] = a6dTemp[4];
    }
  if (5 < nStat)
    {
      m_tReflnProps.a6fReflnSize[4] = a6dTemp[4];
      m_tReflnProps.a6fReflnSize[5] = a6dTemp[5];
    }

  XtFree(pcTemp);

  m_tReflnProps.sReflnColor   = _cUIom9Color->pcGetLabel();
  m_tReflnProps.nReflnSymbol  = _cUIom9Symbol->nGetValue();
  m_tReflnProps.nReflnPredObs = _cUIom9PredObs->nGetValue();

//    cout << "Reflection Size0 set to " << m_tReflnProps.a6fReflnSize[0] << endl;
//    cout << "Reflection Size1 set to " << m_tReflnProps.a6fReflnSize[1] << endl;
//    cout << "Reflection Color set to " << m_tReflnProps.sReflnColor << endl;
//    cout << "Reflection Symbol set to #" << m_tReflnProps.nReflnSymbol << endl;
//    cout << "Reflection Pred/Obs set to #" << m_tReflnProps.nReflnPredObs << endl;

}

void
CUIreflnviewprops::vUpdateWidgets(void)
{
  
  // Copy the values in m_tReflnProps to the widgets
  
  char a80cTemp[80];
  Cstring sNothing("");

  _cUIom9Filename->vSetValue(m_nReflnNum);

  for (int nCount = 0; nCount < 9; nCount++)
    {
      if (sNothing == m_sReflnFilename)
	{
	  _cUIom9Filename->vSetButtonLabel(nCount, "No file!");
	  _cUIom9Filename->vButtonSetSensitive(nCount, False);
	}
      else
	{
	  sprintf(a80cTemp, ".%d", nCount);
	  _cUIom9Filename->vSetButtonLabel(nCount, 
					   Cstring(m_sReflnFilename + a80cTemp).string());
	  _cUIom9Filename->vButtonSetSensitive(nCount, True);
	}
    }
  
  if (0.0 < m_tReflnProps.a6fReflnSize[2])
    sprintf(a80cTemp, "%4.1f, %4.1f, %4.1f, %4.1f", m_tReflnProps.a6fReflnSize[0],
	    m_tReflnProps.a6fReflnSize[1], 
	    m_tReflnProps.a6fReflnSize[2],m_tReflnProps.a6fReflnSize[3]);
  else
    sprintf(a80cTemp, "%4.1f,%4.1f", m_tReflnProps.a6fReflnSize[0],
	    m_tReflnProps.a6fReflnSize[1]);

  XmTextFieldSetString(_tfSize, a80cTemp);
  _cUIom9Color->vSetLabel(m_tReflnProps.sReflnColor.string());
  _cUIom9Symbol->vSetValue(m_tReflnProps.nReflnSymbol);
  _cUIom9PredObs->vSetValue(m_tReflnProps.nReflnPredObs);
}

void
CUIreflnviewprops::vSetLabel(Widget w, char *pcLabel)
{
  // Change the label of the widget label input as w to the
  // text specified in pcLabel

  XmString sxTemp;
  sxTemp = XmStringCreateLtoR(pcLabel,
#if (XmVersion >= 1002)
			      XmFONTLIST_DEFAULT_TAG
#else
                              XmSTRING_DEFAULT_CHARSET
#endif
			      );
if (NULL != sxTemp)
    {
      XtVaSetValues(w, XmNlabelString, sxTemp, 
		    XmNrecomputeSize, False, XmNalignment, 
		    XmALIGNMENT_END, 
		    NULL);
      XmStringFree(sxTemp);
    }
}

void
CUIreflnviewprops::vSetValues(const tagReflnProps& rtProps, 
			      const Cstring sReflnFilename, 
			      const int nReflnNum)
{
  m_tReflnProps.nReflnSymbol    = rtProps.nReflnSymbol;
  m_tReflnProps.a6fReflnSize[0] = rtProps.a6fReflnSize[0];
  m_tReflnProps.a6fReflnSize[1] = rtProps.a6fReflnSize[1];
  m_tReflnProps.a6fReflnSize[2] = rtProps.a6fReflnSize[2];
  m_tReflnProps.a6fReflnSize[3] = rtProps.a6fReflnSize[3];
  m_tReflnProps.a6fReflnSize[4] = rtProps.a6fReflnSize[4];
  m_tReflnProps.a6fReflnSize[5] = rtProps.a6fReflnSize[5];
  m_tReflnProps.sReflnColor     = rtProps.sReflnColor;
  m_tReflnProps.nReflnPredObs   = rtProps.nReflnPredObs;

  m_sReflnFilename = sReflnFilename;
  m_nReflnNum = nReflnNum;

  CUIreflnviewprops::vUpdateWidgets();
}

void
CUIreflnviewprops::vGetValues(tagReflnProps* ptProps)
{
  ptProps->nReflnSymbol    = m_tReflnProps.nReflnSymbol;
  ptProps->a6fReflnSize[0] = m_tReflnProps.a6fReflnSize[0];
  ptProps->a6fReflnSize[1] = m_tReflnProps.a6fReflnSize[1];
  ptProps->a6fReflnSize[2] = m_tReflnProps.a6fReflnSize[2];
  ptProps->a6fReflnSize[3] = m_tReflnProps.a6fReflnSize[3];
  ptProps->a6fReflnSize[4] = m_tReflnProps.a6fReflnSize[4];
  ptProps->a6fReflnSize[5] = m_tReflnProps.a6fReflnSize[5];
  ptProps->sReflnColor     = m_tReflnProps.sReflnColor;
  ptProps->nReflnPredObs   = m_tReflnProps.nReflnPredObs;
}

void 
CUIreflnviewprops::vCUIom9CBCallback(XtPointer pObj, Widget w, 
				   XtPointer clientData, XtPointer callData)
{
    CUIreflnviewprops *obj = (CUIreflnviewprops *)pObj;
    obj->vCUIom9CB(pObj, w, clientData, callData);
}

void 
CUIreflnviewprops::vCUIom9CB(XtPointer pObj, Widget w, XtPointer clientData, 
			   XtPointer callData)
{
  intptr_t i;
  //  int i = (int) clientData;
  i = (intptr_t) clientData;

  //  cout << "Pushbutton #" << i << " pressed.\n";
}

// End user code block <tail>
